<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>

<body>
  <script>
    function test(bool) {
      if (bool) {
        return new Promise((resolve, reject) => {
          resolve("成功")
        })
      } else {
        return new Promise((resolve, reject) => {
          reject("失败")
        })
      }
    }
    test(false).then(res => {
      console.log(res)
    }, err => {
      console.log(err)
    })
    // 2.Promise.resolve()   Promise.reject() 静态函数
    function test2(bool) {
      if (bool) {
        return Promise.resolve("成功")
      } else {
        return Promise.reject("失败")
      }
    }
    test2(true).then(res => {
      console.log(res)
    }).catch(err => {
      console.log(err)
    })





  </script>
</body>

</html>